<template>
  <div class="container with-nav-padding">
    <div class="total_record">
      <p class="total_money">累计：￥{{ totalPrice }}</p>
    </div>
    <div v-if="recordList.length">
      <incomeItem  :item="recordList"></incomeItem>
      <load-more @loadMore="loadMore"></load-more>
    </div>
    <div v-else class="no-recorded">
      <div class="bd-wrap">
        <img src="@/assets/待入账收益-assets/no_message.png" alt="" />
        <p class="tips">暂无收益明细</p>
        <div @click="getRecordedList(1)" class="refreshBtn">刷新</div>
      </div>
    </div>
  </div>
</template>

<script>
import { getRecordedList } from "@/api/vip";
import incomeItem from "./component/income-item.vue";
import loadMore from "@/components/load-more";
export default {
  data() {
    return {
      recordList: [],
      page: 1,
      isAll: false,
      loading: false,
      totalPrice: 0
    };
  },
  methods: {
    getRecordedList(page) {
      getRecordedList({ page, type: 1 }).then(res => {
        if (res.status === 200) {
          this.totalPrice = res.data.data.bonus;
          this.recordList.push(...res.data.data.info);
          if (res.data.data.info.length === 0) {
            this.isAll = true;
            this.$dialog.toast({
              mes: "没有更多了",
              timeout: 1000
            });
          }
        }
        this.loading = false;
      });
    },
    loadMore() {
      if (this.loading || this.isAll || this.recordList.length === 0)
        return;
      this.loading = true;
      this.getRecordedList(++this.page);
    }
  },
  components: {
    incomeItem,
    loadMore
  },
  created() {
    this.getRecordedList(1);
  }
};
</script>

<style lang="less" scoped>
.container {
  .clear {
    clear: both;
  }
  .total_record {
    padding: 0.6rem 0.5rem;
    background: #fff;
    margin-bottom:  0.48rem;
    .total_money {
      color: #444444;
      font-size: 0.64rem;
    }
  }
  .bd-wrap {
    text-align: center;
    img {
      margin-top: 4.72rem;
      width: 4.86rem;
      margin-bottom: 1.56rem;
    }
    .tips {
      width: 100%;
      text-align: center;
      height: 0.62rem;
      margin: 0 auto 1.24rem;
      line-height: 0.62rem;
      color: #444444;
      font-size: 0.64rem;
    }
    .refreshBtn {
      width: 5.36rem;
      height: 1.48rem;
      margin: 0 auto;
      line-height: 1.48rem;
      color: #ffffff;
      font-size: 0.64rem;
      background: #0078ff;
      text-align: center;
    }
  }
}
</style>
